Next | Prev | Up | Top | Contents | Index

Implementing a Single Frame Scheduler

When the activities of your real-time program can be handled within a major frame interval by a single CPU, your program needs to create only one Frame Scheduler.

Typically your program has a top-level process (called the master process here) to handle start-up and termination, and one or more activity processes that are dispatched by the Frame Scheduler. The activity processes are typically lightweight processes created using sproc(), but that is not a requirement--the activity processes can be created with fork(), and they need not be children of the master process. (See for instance "Example of Scheduling Separate Programs".)

In general, these are the steps that the master process follows:

  1. Initialize global resources such as memory-mapped segments, memory arenas, files, asynchronous I/O, and other resources.

  2. Lock the address space segments shared by activity processes (see "Locking Pages in Memory"). (When fork() is used, each child process must lock its own address space.)

  3. Create the Frame Scheduler using frs_create_master() (see Table 7-1 on "Library Interface for C Programs").

  4. Change the Frame Scheduler signals or exception policy, if desired (see "Setting Frame Scheduler Signals" and "Setting Exception Policies").

  5. Create the activity processes using sproc() or fork() or, if they are independent processes, get them started and obtain their PID values.

  6. Use frs_enqueue() to queue each activity process to the queue or queues on which it is to run.

    Each activity process independently uses frs_join() to let the Frame Scheduler know it is ready to start real-time execution. This call must follow the frs_enqueue() call for that process. The call blocks until scheduling begins, then returns to start the first frame dispatch of each activity process.

  7. Set up signal handlers for signals from the Frame Scheduler (see "Using Signals Under the Frame Scheduler"). The handlers are set at this time, after creation of the activity processes, so that the activity processes do not inherit them.

  8. Use frs_start() (Table 7-1) to enable scheduling.

    The Frame Scheduler begins scheduling processes as soon as all the activity processes have called frs_join().

  9. Wait for error and termination signals from the Frame Scheduler and for the termination of child processes.

  10. Use frs_destroy() to terminate the Frame Scheduler.

  11. Tidy up the global resources as required.


Next | Prev | Up | Top | Contents | Index